<?php

namespace App\Http\Controllers\Api;

use App\Models\Common\Media;

class DownloadController
{
    public function download()
    {
        $id = @intval(request('id'));
        $media = Media::with(['file'])->find($id);
        $filename = @request('filename') ?: $media->filename;
        return response()->download(storage_path('app/public/' . $media->file->url), $filename);
    }

}
